import { createPinia } from 'pinia';
import { createPersistedState } from 'pinia-plugin-persistedstate';

const pinia = createPinia();

// 配置状态持久化
pinia.use(
  createPersistedState({
    storage: {
      getItem: (key: string) => {
        return uni.getStorageSync(key);
      },
      setItem: (key: string, value: string) => {
        uni.setStorageSync(key, value);
      },
      removeItem: (key: string) => {
        uni.removeStorageSync(key);
      },
    },
  })
);

export default pinia;